home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / tdood111.arc / TDOODLE.ASM < prev    next >
Encoding:
Assembly Source File  |  1980-01-01  |  64.5 KB  |  2,504 lines

  1. comment * WordStar Tab Ruler
  2. L-------!-------!---------------!----!----!----!----!----!----!----!---------------------------R
  3. 12-30-85
  4. *
  5. cseg segment para public 'code'
  6. assume cs:cseg,ds:cseg,es:cseg,ss:cseg
  7.  
  8.  
  9. len_picture=1A91h
  10.  
  11.         org     0h
  12. Zero:                           ;ret to DOS
  13.         org     100h
  14. start:  jmp     init            ;goto initialization routine
  15.  
  16. buffer          db 256 dup(?)
  17. handle          dw ?
  18. char            db ?
  19. filespec_buffer db 256 dup(?) 
  20. space_count     db ?
  21. write           db ?
  22.  
  23. screen_page     db ?
  24. attrib          db ?
  25. mode            db ?
  26. say_color_flag  db 0
  27. cursor          label word
  28.  
  29. max_line        db ?
  30. cur_line        db ?
  31. max_col         db ?
  32. cur_col         db ?
  33. create          db ?
  34. rotate          db ?
  35. space_size      db ?
  36. ins_del_flag    db ?
  37.  
  38. cursor_size     dw ?
  39. screen_seg      dw ?
  40. screen_buffer   dw ?
  41.  
  42. paste_size      dw ?            ; y/x size of paste_buffer
  43. last_x          db ?
  44. last_y          db ?
  45. block_cursor    label word
  46.  cursor_x       db ?
  47.  cursor_y       db ?
  48. quad            db ?
  49. wrap_flag       db ?
  50.  
  51. esc=27
  52. yes=255
  53. no=0
  54.  
  55. dos     macro   function
  56.         mov     ah,function
  57.         int     21h
  58.         endm
  59.  
  60. getkey  macro 
  61.         call    get_keystroke
  62.         endm
  63.  
  64. wait_for_key macro
  65.         local   wfk_1
  66. wfk_1:  getkey
  67.         jz      wfk_1
  68.         endm
  69.  
  70. get_keystroke:
  71.         mov     ah,1
  72.         int     16h
  73.         jz      GK_ret
  74.         pushf
  75.         mov     ah,0
  76.         int     16h
  77.         popf    
  78. GK_ret: ret
  79.  
  80. jump    macro table,item
  81.         mov     bx,offset table
  82.         mov     al,item
  83.         call    table_jump
  84.         endm
  85. ;
  86. search  macro   table,item
  87.         mov     bx,offset table
  88.         mov     ax,item
  89.         call    table_search
  90.         endm
  91. ;
  92. table_jump:
  93.         cmp     cs:[bx],al         ;too big an offset?
  94.         jc      TJ_end
  95.         dec     bx
  96.         mov     ah,0
  97.         add     ax,ax           ;prep offset
  98.         add     bx,ax           ;get actual addr of routine
  99.         jmp     word ptr cs:[bx]     ;go to routine
  100. TJ_end: ret
  101. ;
  102. table_search:
  103.         push    bx
  104.         push    cx              ;search table @ BX for AL
  105.         push    dx
  106.         push    di
  107.         or      al,al           ;2-byter
  108.         jz      TS_10           ;yes, don't clear top
  109.         mov     ah,0            ;otherwise...
  110.         call    capit_al
  111. TS_10:  mov     cl,[bx]         ;get len of $ to search
  112.         mov     ch,0
  113.         mov     di,bx
  114. TS_5:   inc     di              ;skip length
  115.         mov     dx,[di]         ;get table entry
  116.         or      dl,dl           ;test for 2-byter
  117.         jnz     TS_2            ;no
  118.         inc     di
  119.         jmp short TS_3
  120. TS_2:   mov     dh,0            ;clear top byte for cmp
  121. TS_3:   cmp     ax,dx           ;are they the same?
  122.         je      TS_4            ;go if they are
  123.         loop    TS_5            ;else go to end of table
  124.         jmp short TS_1          ;done but not found
  125. TS_4:   mov     ch,[bx]         ;get len of table again
  126.         sub     ch,cl           ;get offset into table
  127.         mov     ah,ch           ;get offset into ah
  128.         inc     ah              ;make go from 1
  129.         xor     bx,bx           ;set flags
  130. TS_1:   pop     di
  131.         pop     dx
  132.         pop     cx
  133.         pop     bx
  134.         ret
  135. ;
  136. capit_al:
  137.         cmp     al,'a'
  138.         jc      CA_1
  139.         cmp     al,'z'+1
  140.         jnc     CA_1
  141.         sub     al,32
  142. CA_1:   ret
  143.  
  144. retf    macro   pop_value
  145.  ifb <pop_value>
  146.         db      0cbH            ;far ret w/no [pop-value]
  147.  else
  148.         db      0caH            ;far ret w/pop-value
  149.         dw      pop_value
  150.  endif
  151.         endm
  152. ;
  153.  
  154. ceol db esc,'[K$'
  155.  
  156. print_cs_space:
  157.         mov     ah,9
  158.         int     21h
  159.         mov     dl,32
  160.         mov     ah,2
  161.         int     21h
  162.         ret
  163.  
  164. print_cs:
  165.         mov     ah,9
  166.         int     21h
  167.         mov     dx,offset ceol
  168.         mov     ah,9
  169.         int     21h
  170.         ret
  171.  
  172.  
  173. save_screen:
  174.         mov     si,0
  175.         mov     di,[screen_buffer]
  176.         mov     ax,screen_seg
  177.         mov     ds,ax
  178.         mov     cx,1760
  179.         rep     movsw
  180.         mov     ax,es
  181.         mov     ds,ax
  182.         ret
  183.  
  184. MU_undo:
  185. restore_screen:
  186.         pushf
  187.         push    ax
  188.         push    cx
  189.         push    si
  190.         push    di
  191.         mov     ax,screen_seg
  192.         mov     es,ax
  193.         mov     si,[screen_buffer]
  194.         mov     di,0
  195.         mov     cx,1760
  196.         rep     movsw
  197.         mov     ax,ds
  198.         mov     es,ax
  199.         pop     di
  200.         pop     si
  201.         pop     cx
  202.         pop     ax
  203.         popf
  204.         ret
  205.  
  206.  
  207. memory_error db 'Memory allocation error (not enough, or bad allocation blocks)',13,10,10
  208.  
  209. ansi_test db esc,'[H',8,8,8,'   ',8,8,8,'$'
  210. ansi_error db 13,10,'tDoodle 1.11',13,10,'Please add the following line to your '
  211.            db 'CONFIG.SYS file:',13,10,10
  212.            db 'DEVICE=ANSI.SYS',13,10,10,'$'
  213.  
  214. break_handler:
  215.         iret
  216.  
  217. No_parm:
  218.         call    cls
  219.         mov     cx,len_picture
  220.         mov     dx,offset screen_buffer_1
  221.         mov     bx,0            ;CON
  222.         mov     ah,40h          ;write to file
  223.         int     21h
  224. np_1:   getkey
  225.         jnz     np_1
  226. np_2:   getkey
  227.         jz      np_2
  228.  
  229.         call    cls
  230.         jmp     editor
  231.  
  232. bad_dos_version db 'tDoodle 1.00: Incorrect DOS Version.$'
  233.  
  234. ;************* Start *********************
  235. init:   mov     ah,30h
  236.         int     21h             ;get DOS ver #
  237.         cmp     al,2
  238.         jae     init_9
  239.         mov     dx,offset bad_dos_version
  240.         mov     ah,9
  241.         int     21h
  242.         jmp     zero
  243.  
  244. init_9: mov     bh,0
  245.         mov     ah,3
  246.         int     10h             ;get curpos
  247.         push    dx
  248.         mov     dh,24
  249.         mov     dl,0
  250.         mov     ah,2
  251.         int     10h             ;set curpos
  252.         mov     dx,offset ansi_test
  253.         dos     9
  254.         mov     ah,3
  255.         int     10h
  256.         or      dx,dx
  257.         pop     dx
  258.         pushf
  259.         mov     ah,2
  260.         int     10h             ;restore cursor
  261.         popf
  262.         jz      ansi_installed
  263.         mov     dx,offset ansi_error
  264.         dos     9
  265.         jmp     zero            ;terminate (no ANSI.SYS)
  266.  
  267. parm_error_so:
  268.         jmp     parm_error
  269.  
  270. ansi_installed:
  271.         mov     bx,offset end_of_code
  272.         mov     cl,4
  273.         shr     bx,cl           ;turn byte count into para's
  274.         inc     bx
  275.         mov     ah,4Ah
  276.         int     21h
  277.         jnc     init_10
  278.         mov     dx,offset Memory_error
  279.         call    print_cs
  280.         jmp     zero
  281.  
  282. no_parm_so: 
  283.         jmp no_parm
  284.  
  285. init_10:
  286.         mov     ah,25h          ;get ^Break addr
  287.         mov     al,23h          ;^BREAK int #
  288.         mov     dx,offset Break_handler
  289.         int     21h
  290.         
  291.         mov     ah,3
  292.         int     10h             ;get cursor size
  293.         mov     cursor_size,cx
  294.         call    fix_cursor_block
  295.  
  296.         mov     screen_buffer,offset screen_buffer_1
  297.         
  298.         mov     di,offset filespec_buffer
  299.         mov     al,64
  300.         stosb
  301.  
  302.         mov     si,80h          ;parameter addr
  303.         lodsb                   ;get len of command$
  304.         mov     bl,al
  305.         mov     bh,0
  306.         or      bl,bh           ;is len(parm)=0?
  307.         jz      No_Parm_so
  308.         mov     byte ptr [si+bx],0   ;terminate ASCIIZ
  309.  
  310. init_loop_1:
  311.         lodsb                   ;get char of $
  312.         or      al,al           ;EOS?
  313.         jz      Parm_error_so
  314.         cmp     al,13           ;EOS?
  315.         jz      Parm_error_so
  316.         cmp     al,9            ;nothing?
  317.         jz      init_loop_1
  318.         cmp     al,32           ;space?
  319.         jz      init_loop_1
  320.         dec     si
  321.  
  322.         push    si
  323.         mov     cl,0
  324.         inc     di
  325. init_1: lodsb
  326.         stosb
  327.         inc     cl
  328.         cmp     al,0            ;EOS?
  329.         jne     init_1
  330.         dec     cl
  331.         mov     byte ptr [filespec_buffer+1],cl
  332.         pop     si
  333.  
  334.         mov     dx,si
  335.         mov     al,2            ;open for r/w
  336.         mov     ah,3Dh
  337.         int     21h             ;open file
  338.         jnc     Load_File_so
  339.         cmp     al,2
  340.         jnz     File_open_error
  341.         mov     dx,si
  342.         mov     ah,3Ch
  343.         mov     cx,0
  344.         int     21h
  345.         jc      File_open_error
  346. Load_file_so:
  347.         jmp     Load_file
  348.  
  349. Parm_error_message db 'Bad parameter line',13,10,'$'
  350. File_open_error_message db 'Couldn',27h,'t open file',13,10,'$'
  351. Load_error_message db 'Had trouble loading file.',13,10,'$'
  352.  
  353. Parm_error:
  354.         mov     dx,offset Parm_error_message
  355.         call    print_cs
  356.         jmp     ret_to_dos
  357. File_open_error:
  358.         mov     dx,offset File_open_error_message
  359.         call    print_cs
  360.         jmp     ret_to_dos
  361. Load_error:
  362.         mov     byte ptr [di-1],13
  363.         mov     bx,handle
  364.         mov     ah,3Eh
  365.         int     21h
  366.         mov     dx,offset Load_error_message
  367.         call    print_cs
  368. Ret_to_DOS_2:
  369. Ret_to_DOS:
  370.         jmp     Zero
  371.  
  372. cls_string db esc,'[=2h',esc,'[?7h',esc,'[0m',esc,'[2J','$'
  373.  
  374. cls:    mov     dx,offset cls_string
  375.         call    print_cs
  376.         mov     attrib,7
  377.         call    fix_cursor_block
  378.         ret
  379.  
  380. Load_File:
  381.         mov     handle,ax
  382.  
  383.         call    cls
  384. Load_loop:
  385.         mov     bx,handle
  386.         mov     ah,3Fh
  387.         mov     cx,1
  388.         mov     dx,offset buffer
  389.         int     21h
  390.         jc      Load_Error
  391.         or      ax,ax
  392.         jz      Load_Ended
  393.  
  394.         mov     dl,byte ptr [buffer]
  395.         cmp     dl,26           ;^Z terminating?
  396.         jz      Load_Ended
  397.  
  398.         mov     ah,2
  399.         int     21h
  400.         jmp     Load_loop
  401.  
  402. Load_Ended:
  403.         mov     bx,handle
  404.         mov     ah,3Eh
  405.         int     21h             ;close file
  406.  
  407.         mov     cx,0            ;home cursor
  408.         call    set_cur_pos
  409.         jmp     Editor
  410.  
  411. text_table db 17
  412.         db 8     ;bksp
  413.         db 13    ;RET
  414.         db 0,71  ;HOME
  415.         db 0,72  ;up
  416.         db 0,73  ;PgUp
  417.         db 0,75  ;lt
  418.         db 0,77  ;rt
  419.         db 0,79  ;END
  420.         db 0,80  ;dn
  421.         db 0,81  ;PgDn
  422.         db 27    ;ESC
  423.         db 0,82  ;INS
  424.         db 0,83  ;DEL
  425.         db 9     ;TAB
  426.         db 0,115 ;^lt
  427.         db 0,116 ;^rt
  428.         db 0,119 ;^HOME
  429.  
  430.  
  431.  
  432. text_jmp_table db 17
  433.         dw offset key_bksp
  434.         dw offset key_cr
  435.         dw offset key_home
  436.         dw offset key_up
  437.         dw offset key_pgup
  438.         dw offset key_lt
  439.         dw offset key_rt
  440.         dw offset key_end
  441.         dw offset key_dn
  442.         dw offset key_pgdn
  443.         dw offset key_esc
  444.         dw offset key_ins
  445.         dw offset key_del
  446.         dw offset key_tab
  447.         dw offset key_ctrl_lt
  448.         dw offset key_ctrl_rt
  449.         dw offset key_ctrl_home
  450.  
  451. cmd_key db 10, esc,'GRCSLQWFU'
  452.  
  453. cmd_table db 10
  454.         dw offset cmd_esc       ;toggle to/from text/cmd
  455.         dw offset cmd_G         ;replace IBM graphics
  456.         dw offset cmd_R         ;replace (not implemented)
  457.         dw offset cmd_C         ;set Colors
  458.         dw offset cmd_S         ;Save file
  459.         dw offset cmd_L         ;Load file
  460.         dw offset cmd_Q         ;Quit tDoodle
  461.         dw offset cmd_W         ;Wipe out screen (cls)
  462.         dw offset cmd_F         ;Flip between screens
  463.         dw offset cmd_U         ;Undo (edit: F9)
  464.  
  465. box_key_table db 22, '12345678QWEASDZXC-_\| '
  466. box_table_list label word
  467.         dw offset box_table_1
  468.         dw offset box_table_2
  469.         dw offset box_table_3
  470.         dw offset box_table_4
  471.  
  472. box_table_1 db 176,177,178,219,220,223,221,222
  473.             db 218,194,191,195,197,180,192,193,217,196,196,179,179,32
  474. box_table_2 db 176,177,178,219,220,223,221,222
  475.             db 201,203,187,204,206,185,200,202,188,205,205,186,186,32
  476. box_table_3 db 176,177,178,219,220,223,221,222
  477.             db 213,209,184,198,216,181,212,207,190,205,205,179,179,32
  478. box_table_4 db 176,177,178,219,220,223,221,222
  479.             db 214,210,183,199,215,182,211,208,189,196,196,186,186,32
  480.  
  481. fn_table db 10
  482.         db 0,59                 ;F1: rotate box modes
  483.         db 0,60                 ;F2: set csr attr to cur attr
  484.         db 0,61                 ;F3: reverse screen attribs
  485.         db 0,62                 ;F4: rotate paint/text/both 
  486.         db 0,63                 ;F5: show colors
  487.         db 0,64                 ;F6: Flip from one screen to the other
  488.         db 0,65                 ;F7: Pickup
  489.         db 0,66                 ;F8: PutDown
  490.         db 0,67                 ;F9: Undo
  491.         db 0,68                 ;F0: ASCII table
  492.  
  493. mode_update_table db 10
  494.         dw offset MU_boxes
  495.         dw offset MU_attrib
  496.         dw offset MU_reverse
  497.         dw offset MU_put_mode
  498.         dw offset MU_show_colors
  499.         dw offset MU_flip
  500.         dw offset MU_Pickup
  501.         dw offset MU_PutDown
  502.         dw offset MU_Undo
  503.         dw offset MU_ascii
  504.  
  505. key_ctrl_home:
  506.         call    get_cur
  507.         mov     cl,39
  508.         jmp     set_cur_pos
  509. key_ctrl_rt:
  510.         call    get_cur
  511.         mov     cl,78
  512.         jmp     set_cur_pos
  513. key_ctrl_lt:
  514.         call    get_cur
  515.         mov     cl,0
  516.         jmp     set_cur_pos
  517. key_lt: call    get_cur
  518.         cmp     cl,0
  519.         jz      KL_1
  520.         dec     cl
  521. SCP:    jmp     Set_cur_pos
  522. KL_1:   cmp     wrap_flag,255
  523.         jne     scp
  524.         mov     cl,78
  525. Key_up_2:
  526.         or      ch,ch
  527.         jz      Set_cur_pos
  528.         dec     ch
  529.         jmp     Set_Cur_pos
  530. Key_cr:
  531.         call    get_cur
  532.         cmp     ch,21
  533.         jz      Set_Cur_pos
  534.         inc     ch
  535.         mov     cl,0
  536.         jmp     Set_Cur_pos
  537. Key_rt: call    get_cur
  538.         cmp     cl,78
  539.         jne     KR_1
  540.         cmp     wrap_flag,255
  541.         jne     set_cur_pos
  542.         jmp     Key_cr
  543. KR_1:   inc     cl
  544. Set_cur_pos:
  545.         mov     ah,2
  546.         mov     bh,screen_page
  547.         mov     dx,cx
  548.         int     10h
  549.         cmp     say_color_flag,0
  550.         jz      SCP_ret
  551.         call    say_color
  552. SCP_ret:
  553.         ret
  554. Key_up: call    get_cur
  555.         jmp     Key_up_2
  556. Key_dn: call    get_cur
  557.         cmp     ch,21
  558.         jz      Set_cur_pos
  559.         inc     ch
  560.         jmp     Set_cur_pos
  561. Key_home:
  562.         mov     cx,0
  563.         jmp     Set_cur_pos
  564. Key_PgUp:
  565.         call    Key_up
  566.         call    key_rt
  567.         ret
  568. Key_PgDn:
  569.         call    Key_dn
  570.         call    key_rt
  571.         ret
  572. Key_End:
  573.         mov     cx,21*256
  574.         jmp     Set_cur_pos
  575. key_bksp:
  576.         call    key_lt
  577.         mov     al,32           ;print space
  578.         mov     ah,attrib       ;in current attrib
  579.         call    alt_modes
  580.         mov     bh,0
  581.         mov     cx,1
  582.         mov     ah,9
  583.         int     10h
  584.         ret
  585. get_cur:
  586.         mov     ah,3
  587.         mov     bh,screen_page
  588.         int     10h
  589.         mov     cx,dx
  590.         ret
  591. key_esc:
  592.         clc
  593.         call    save_cur
  594.         pop     ax
  595.         ret
  596.  
  597. key_ins:
  598.         mov     bh,screen_page
  599.         mov     ah,3
  600.         int     10h
  601.         mov     cursor,dx
  602.         mov     al,attrib
  603.         push    ax
  604.  
  605.         mov     ins_del_flag,255
  606.         push    dx              ;save it for later
  607.         mov     dl,78           ;last col
  608.  
  609. KI_1:   dec     dl
  610.         mov     ah,2            ;set curpos
  611.         int     10h
  612.         mov     ah,8
  613.         int     10h             ;read c/a
  614.         mov     attrib,ah
  615.         push    ax
  616.  
  617.         inc     dl
  618.         mov     ah,2
  619.         int     10h
  620.         pop     ax
  621.         push    dx
  622.         call    alt_modes
  623.         pop     dx
  624.         mov     cx,1
  625.         mov     ah,9
  626.         int     10h             ;write c/a
  627.  
  628.         dec     dl
  629.         pop     cx
  630.         cmp     dl,cl
  631.         push    cx
  632.         jne     KI_1
  633.         pop     cx
  634.         mov     ah,2
  635.         int     10h             ;reset cursor
  636.  
  637.         pop     ax
  638.         mov     attrib,al
  639.         mov     al,32
  640.         call    alt_modes
  641.         mov     cx,1
  642.         mov     ah,9
  643.         int     10h
  644.  
  645.         mov     ins_del_flag,0
  646.         ret
  647.  
  648. key_del:
  649.         mov     bh,screen_page
  650.         mov     ah,3
  651.         int     10h             ;get curpos
  652.         mov     cursor,dx
  653.         mov     al,attrib
  654.         push    ax
  655.  
  656.         mov     ins_del_flag,255
  657.  
  658. kd_1:   inc     dl              ;next col over
  659.         mov     ah,2
  660.         int     10h
  661.         mov     ah,8
  662.         int     10h             ;get c/a
  663.         mov     attrib,ah
  664.         push    ax
  665.  
  666.         dec     dl
  667.         mov     ah,2
  668.         int     10h
  669.         pop     ax
  670.         push    dx
  671.         call    alt_modes
  672.         pop     dx
  673.         mov     cx,1
  674.         mov     ah,9
  675.         int     10h
  676.  
  677.         inc     dl
  678.         cmp     dl,78
  679.         jne     kd_1
  680.         mov     ah,2
  681.         int     10h
  682.  
  683.         pop     ax
  684.         mov     attrib,al
  685.         mov     al,32
  686.         call    alt_modes
  687.         mov     cx,1
  688.         mov     ah,9
  689.         int     10h
  690.  
  691.         mov     dx,cursor
  692.         mov     ah,2
  693.         int     10h
  694.         mov     ins_del_flag,0
  695.         ret
  696.  
  697. key_tab:
  698.         mov     bh,screen_page
  699.         mov     ah,3
  700.         int     10h             ;get curpos
  701.         mov     cl,3
  702.         sar     dl,cl
  703.         inc     dl
  704.         sal     dl,cl
  705.         and     dl,255-7
  706.         cmp     dl,78
  707.         jbe     kt_cont
  708.         mov     dl,78
  709.         cmp     dh,22
  710.         je      kt_cont
  711.         inc     dh
  712.         mov     dl,0
  713.  
  714. kt_cont:
  715.         mov     ah,2
  716.         int     10h
  717.         ret
  718.  
  719. fix_cursor_block:
  720.         mov     ah,15
  721.         int     10h             ;get screen mode
  722.         mov     screen_page,bh
  723.         mov     cx,12           
  724.         mov     dx,0B000h       ;mono seg
  725.         mov     say_color_flag,255
  726.         cmp     al,7            ;monochrome
  727.         jz      set_cursor_block
  728.         mov     cl,7
  729.         mov     dx,0B800h       ;cga seg
  730.         mov     say_color_flag,0
  731. set_cursor_block:
  732.         mov     screen_seg,dx
  733.         mov     ah,1
  734.         int     10h             ;set new cursor 
  735.         ret
  736.  
  737. restore_cursor_block:
  738.         mov     cx,cursor_size
  739.         mov     ah,1
  740.         int     10h
  741.         ret
  742.  
  743.  
  744. Editor: mov     attrib,7        ;default, white on black
  745.         mov     mode,0          ;text mode
  746.         call    mu_flip
  747.         call    cls
  748.         call    mu_flip
  749.  
  750. Editor_loop:
  751.         mov     wrap_flag,255
  752.         call    display_ctrls
  753.         call    mode_text       ;go update screen
  754.         call    mode_cmd
  755.         jnc     Editor_loop
  756.         call    restore_cursor_block
  757.         jmp     Ret_to_DOS_2
  758.  
  759. mode_text:
  760.         getkey  
  761.         jz      mode_text
  762.         push    ax
  763.         search  text_table,ax
  764.         jnz     MT_text
  765.         pop     dx
  766.         jump    text_jmp_table,ah
  767.         jmp     mode_text
  768. MT_text:
  769.         pop     ax              ;get back key
  770.         push    ax              ;and save it back
  771.         search  fn_table,ax
  772.         je      mode_update
  773.         pop     ax
  774.         or      al,al
  775.         jz      mode_text       ;bad keystroke
  776.         cmp     al,32
  777.         jb      mode_text
  778.         call    alt_modes
  779.         mov     cx,1
  780.         mov     ah,9
  781.         int     10h
  782.         call    key_rt
  783.         jmp     mode_text
  784.  
  785. mode_update:
  786.         pop     dx              ;clear stack
  787.         jump    mode_update_table,ah
  788.         mov     wrap_flag,255
  789.         jmp     mode_text
  790.  
  791. MU_boxes:
  792.         mov     ah,mode
  793.         test    ah,128
  794.         jz      F1_start
  795.         mov     al,ah
  796.         and     al,252
  797.         inc     ah
  798.         and     ah,3
  799.         or      ah,ah
  800.         jz      F1_end
  801.         or      ah,al
  802.         mov     mode,ah
  803.         call    display_ctrls
  804.         ret
  805. F1_end: and     al,127
  806.         mov     mode,al
  807.         call    display_ctrls
  808.         ret
  809. F1_start:
  810.         or      ah,128
  811.         and     ah,252
  812.         mov     mode,ah
  813.         call    display_ctrls
  814.         ret
  815.  
  816. MU_attrib:
  817.         mov     ah,8
  818.         mov     bh,screen_page
  819.         int     10h
  820.         mov     attrib,ah
  821.         call    display_ctrls
  822.         ret
  823.  
  824. MU_reverse:
  825.         mov     ah,attrib
  826.         mov     al,ah
  827.         mov     cl,4
  828.         ror     ah,cl
  829.         and     ah,255-(128+8)  ;clear int/blnk bits
  830.         and     al,128+8
  831.         or      ah,al           ;move old blnk/int into attribs
  832.         mov     attrib,ah
  833.         call    display_ctrls
  834.         ret
  835.  
  836. MU_put_mode:
  837.         mov     ah,mode
  838.         mov     cl,5
  839.         ror     ah,cl
  840.         and     ah,3
  841.         test    ah,1            ;not "both"?
  842.         jnz     MU_pm_1         ;go if not "both"
  843.         mov     ah,1
  844. MU_pm_3:
  845.         mov     al,mode
  846.         and     al,255-96       ;clear out current mode
  847.         rol     ah,cl
  848.         or      al,ah
  849.         mov     mode,al       ;set new one
  850.         call    display_ctrls
  851.         ret
  852. MU_pm_1:
  853.         xor     ah,2            ;set 0 to 1
  854.         test    ah,2            ;is it 0
  855.         jz      MU_pm_2
  856.         jmp     MU_pm_3
  857. MU_pm_2:
  858.         mov     ah,0
  859.         jmp     MU_pm_3
  860.  
  861.  
  862. mu_sc_setup db esc,'[24;1f$'
  863.  
  864. mu_sc_colors db 8
  865.         dw offset mu_black
  866.         dw offset mu_blue
  867.         dw offset mu_green
  868.         dw offset mu_cyan
  869.         dw offset mu_red
  870.         dw offset mu_magenta
  871.         dw offset mu_yellow
  872.         dw offset mu_white
  873.  
  874. mu_black        db 'Black$'
  875. mu_blue         db 'Blue$'
  876. mu_green        db 'Green$'
  877. mu_cyan         db 'Cyan$'
  878. mu_red          db 'Red$'
  879. mu_magenta      db 'Magenta$'
  880. mu_yellow       db 'Yellow$'
  881. mu_white        db 'White$'
  882.  
  883. mu_blinking     db 'Blinking$'
  884. mu_bright       db 'Bright$'
  885. mu_on           db 'on$'
  886. mu_comma        db 8,',$'
  887.  
  888. MU_show_colors:
  889.         xor     say_color_flag,255
  890.         cmp     say_color_flag,0
  891.         jne     say_color
  892.         ret
  893.  
  894. say_color:
  895.         push    ax
  896.         push    bx
  897.         push    cx
  898.         push    dx
  899.         push    si
  900.         push    di
  901.  
  902.         mov     bh,screen_page
  903.         mov     ah,8
  904.         int     10h             ;get c/a
  905.         push    ax
  906.  
  907.         mov     ah,3
  908.         int     10h             ;get curpos
  909.         mov     cursor,dx
  910.  
  911.         mov     dx,offset mu_sc_setup
  912.         call    print_cs
  913.  
  914.         pop     ax              ;get c/a
  915.         push    ax
  916.         test    ah,8            ;bright?
  917.         jz      MU_sc_1
  918.         mov     dx,offset mu_bright
  919.         call    print_cs_space
  920.         pop     ax 
  921.         push    ax
  922.         test    ah,128          ;blinking?
  923.         jz      mu_sc_1
  924.         mov     dx,offset mu_comma
  925.         call    print_cs_space
  926.         pop     ax
  927.         push    ax
  928. mu_sc_1:
  929.         test    ah,128          ;blinking?
  930.         jz      mu_sc_2
  931.         mov     dx,offset mu_blinking
  932.         call    print_cs_space
  933.         pop     ax
  934.         push    ax
  935. mu_sc_2:
  936.         and     ah,7            ;get foreground color
  937.         mov     al,ah
  938.         mov     ah,0
  939.         add     ax,ax
  940.         mov     bx,ax
  941.         inc     bx
  942.         mov     si,offset mu_sc_colors
  943.         mov     dx,[si+bx]
  944.         call    print_cs_space
  945.         mov     dx,offset mu_on
  946.         call    print_cs_space
  947.         pop     ax
  948.         mov     cl,4
  949.         ror     ah,cl
  950.         and     ah,7
  951.         mov     al,ah
  952.         mov     ah,0
  953.         add     ax,ax
  954.         mov     bx,ax
  955.         inc     bx
  956.         mov     dx,[si+bx]
  957.         call    print_cs
  958.  
  959.         mov     dx,cursor
  960.         mov     ah,2
  961.         mov     bh,screen_page
  962.         int     10h
  963.  
  964.         pop     di
  965.         pop     si
  966.         pop     dx
  967.         pop     cx
  968.         pop     bx
  969.         pop     ax
  970.         ret
  971.  
  972.  
  973. alt_modes:
  974.         test    mode,128        ;is graphic active?
  975.         jz      AM_paint        ;no, go check attr only
  976.         test    ins_del_flag,1  ;no box conv?
  977.         jnz     AM_paint
  978.         search  box_key_table,ax
  979.         je      AM_1
  980.         pop     ax              ;clear stack
  981.         jmp     mode_text
  982. AM_1:   mov     dl,mode
  983.         mov     dh,0
  984.         and     dl,3
  985.         add     dx,dx
  986.         mov     bx,offset box_table_list
  987.         add     bx,dx
  988.         mov     bx,cs:[bx]      ;get addr of xlat table
  989.         dec     ah
  990.         mov     al,ah
  991.         mov     ah,0
  992.         add     bx,ax
  993.         mov     al,cs:[bx]      ;get xlated box part
  994.  
  995. AM_paint:                       ;t/a lockout? 
  996.         push    ax
  997.         test    mode,32
  998.         jz      AM_normal
  999.         mov     bh,screen_page
  1000.         mov     ah,8
  1001.         int     10h             ;get c/a
  1002.         test    mode,64         ;text only?
  1003.         jz      AM_attr         ;no, attr only.
  1004.         mov     bl,ah           ;set attr to what's under cur
  1005.         mov     bh,screen_page
  1006.         pop     ax              ;recover text
  1007.         ret
  1008.  
  1009. AM_attr:
  1010.         pop     dx              ;scrap old text
  1011.         mov     bh,screen_page
  1012.         mov     bl,attrib
  1013.         ret
  1014.  
  1015. AM_normal:
  1016.         pop     ax
  1017.         mov     bh,screen_page
  1018.         mov     bl,attrib
  1019.         ret
  1020.  
  1021. mup_inst db esc,'[24;1fUse ',24,' ',25,' ',26,' and ',27,' to move,',13,10
  1022.         db 'F7 to set other end of block, ESC to abort CUT.$'
  1023.  
  1024.  
  1025. mu_Pickup:
  1026.         call    save_screen
  1027.         call    save_cur
  1028.         mov     al,say_color_flag
  1029.         mov     ah,attrib
  1030.         push    ax
  1031.         mov     say_color_flag,0
  1032.         mov     wrap_flag,0
  1033.         mov     di,0700h
  1034.         mov     si,00FFh        ;setup for CLS2
  1035.         mov     dx,0            ;csrpos
  1036.         mov     bh,screen_page
  1037.         push    cursor
  1038.         call    cls2
  1039.         pop     cursor
  1040.  
  1041.         mov     dx,offset mup_inst
  1042.         call    print_cs
  1043.         call    restore_cur
  1044.         mov     dx,cursor
  1045.         mov     block_cursor,dx
  1046.         mov     last_x,dl
  1047.         mov     last_y,dh
  1048.         call    fix_block
  1049.  
  1050. mup_1:  getkey
  1051.         jz      mup_1
  1052.         cmp     ax,4100h        ;F7?
  1053.         je      mup_2
  1054.  
  1055.         search  text_table,ax
  1056.         jne     mup_1
  1057.         cmp     ah,2
  1058.         je      mup_1
  1059.         cmp     ah,3
  1060.         je      mup_1
  1061.         cmp     ah,8
  1062.         je      mup_1
  1063.         cmp     ah,12
  1064.         je      mup_1
  1065.         cmp     ah,13
  1066.         je      mup_1
  1067.         cmp     ah,11
  1068.         je      mup_esc
  1069.         cmp     ah,14
  1070.         jnc     mup_1
  1071.         jump    text_jmp_table,ah
  1072.         call    fix_block
  1073.         jmp     mup_1
  1074. mup_esc:
  1075.         pop     ax
  1076.         mov     say_color_flag,al
  1077.         mov     attrib,ah
  1078.         call    restore_screen
  1079.         call    display_ctrls
  1080.         call    restore_cur
  1081.         ret
  1082.  
  1083. mup_2:  mov     bh,screen_page
  1084.         mov     ah,3            ;read curpos
  1085.         int     10h
  1086.         mov     cx,block_cursor
  1087.         cmp     ch,dh           ;make DX hold bigger y/x
  1088.         jbe     mup_3
  1089.         xchg    ch,dh
  1090. mup_3:  cmp     cl,dl
  1091.         jbe     mup_4
  1092.         xchg    cl,dl
  1093.  
  1094. mup_4:  push    dx              ;save bigger values
  1095.         sub     dx,cx
  1096.         inc     dl
  1097.         inc     dh              ;make go from 1
  1098.         mov     paste_size,dx   ;set y/x of block size
  1099.         pop     dx
  1100.  
  1101.         call    restore_screen
  1102.         mov     di,offset paste_buffer
  1103.         xchg    cx,dx           ;move small curpos to cursor register
  1104.         
  1105. mup_6:  push    dx
  1106. mup_5:  mov     ah,2
  1107.         int     10h
  1108.         mov     ah,8
  1109.         int     10h
  1110.         stosw
  1111.  
  1112.         cmp     dl,cl
  1113.         je      mup_next_line
  1114.         inc     dl
  1115.         jmp     mup_5
  1116.  
  1117. mup_next_line:
  1118.         pop     dx
  1119.         cmp     dh,ch
  1120.         je      mup_end
  1121.         inc     dh
  1122.         jmp     mup_6
  1123.  
  1124. mup_end:
  1125.         jmp     mup_esc
  1126.  
  1127.  
  1128. fb_y_more:
  1129.         jmp     fb_y_more_routine
  1130.  
  1131. fix_block:
  1132.         mov     bh,screen_page
  1133.         mov     ah,3
  1134.         int     10h             ;get curpos
  1135.         cmp     dl,last_x
  1136.         jb      fb_x_less
  1137.         ja      fb_x_more
  1138.         call    fb_center
  1139. fb_1:   cmp     dh,last_y
  1140.         jb      fb_y_less
  1141.         ja      fb_y_more
  1142.         call    fb_center
  1143. fb_2:   mov     last_x,dl
  1144.         mov     last_y,dh
  1145.         mov     ah,2
  1146.         int     10h             ;reset curpos
  1147.         ret
  1148.  
  1149. fb_x_less:
  1150.         cmp     dl,cursor_x
  1151.         jb      fbxl_less
  1152.  
  1153.         mov     cl,last_x
  1154.         cmp     dl,cl
  1155.         push    dx
  1156.         mov     attrib,7
  1157.         mov     dh,last_y
  1158.         jbe     fbxl_1
  1159.         xchg    dl,cl
  1160. fbxl_1: inc     dl
  1161.         call    fb_v_line
  1162.         cmp     dl,cl
  1163.         jne     fbxl_1
  1164.         pop     dx
  1165.         jmp     fb_1
  1166.  
  1167. fbxl_less:
  1168.         mov     cl,last_x
  1169.         cmp     dl,cl
  1170.         push    dx
  1171.         mov     attrib,7*16
  1172.         jae     fbxl_2
  1173.         xchg    dl,cl
  1174. fbxl_2: call    fb_v_line
  1175.         cmp     dl,cl
  1176.         je      fbxl_3
  1177.         dec     dl
  1178.         jmp     fbxl_2
  1179. fbxl_3: pop     dx
  1180.         jmp     fb_1
  1181.  
  1182. fb_x_more:
  1183.         cmp     dl,cursor_x
  1184.         ja      fbxl_less
  1185.  
  1186.         mov     cl,last_x
  1187.         push    dx
  1188.         mov     attrib,7
  1189.         mov     dh,last_y
  1190.         cmp     dl,cl
  1191.         jbe     fbxm_1
  1192.         xchg    dl,cl
  1193. fbxm_1: call    fb_v_line
  1194.         inc     dl
  1195.         cmp     dl,cl
  1196.         jne     fbxm_1
  1197.         pop     dx
  1198.         jmp     fb_1
  1199.  
  1200. fb_y_less:
  1201.         mov     quad,0
  1202.         cmp     dh,cursor_y
  1203.         mov     quad,0
  1204.         jb      fbyl_less
  1205.         mov     quad,255
  1206. fbym_1: mov     ch,last_y
  1207.         cmp     dh,ch
  1208.         push    dx
  1209.         mov     attrib,7
  1210.         mov     dl,last_x
  1211.         jbe     fbyl_1
  1212.         xchg    dh,ch
  1213. fbyl_1: call    fbyl_fix_quad_3_4
  1214. fbyl_2: call    fb_h_line
  1215.         inc     dh
  1216.         cmp     dh,ch
  1217.         jne     fbyl_2
  1218.         pop     dx
  1219.         jmp     fb_2
  1220.  
  1221. fbyl_less:
  1222.         mov     ch,last_y
  1223.         cmp     dh,ch
  1224.         push    dx
  1225.         mov     attrib,7*16
  1226.         jae     fbyl_4
  1227.         xchg    dh,ch
  1228. fbyl_4: dec     ch
  1229.  
  1230. fbyl_3: call    fb_h_line
  1231.         dec     dh
  1232.         cmp     dh,ch
  1233.         jne     fbyl_3
  1234.         pop     dx
  1235.         jmp     fb_2
  1236.  
  1237. fb_y_more_routine:
  1238.         cmp     dh,cursor_y
  1239.         mov     quad,255
  1240.         ja      fbyl_less
  1241.         mov     quad,0
  1242.         jmp     fbym_1
  1243.  
  1244. fbyl_fix_quad_3_4:
  1245.         test    quad,255
  1246.         jz      fbylfq34_ret
  1247.         inc     ch
  1248.         inc     dh
  1249. fbylfq34_ret:
  1250.         ret
  1251.  
  1252. fb_v_line:
  1253.         push    dx
  1254.         push    cx
  1255.         mov     bh,screen_page
  1256.  
  1257.         mov     ch,cursor_y
  1258.         cmp     dh,ch
  1259.         jbe     fbvl_1
  1260.         xchg    dh,ch
  1261.  
  1262. fbvl_1: mov     ah,2            ;set curpos
  1263.         int     10h
  1264.         mov     ah,8
  1265.         int     10h             ;read c/a
  1266.  
  1267.         push    cx
  1268.         mov     bl,attrib
  1269.         mov     cx,1
  1270.         mov     ah,9
  1271.         int     10h             ;write new attrib
  1272.         pop     cx
  1273.  
  1274.         cmp     dh,ch
  1275.         je      fbvl_2
  1276.         inc     dh
  1277.         jmp     fbvl_1
  1278.  
  1279. fbvl_2: pop     cx
  1280.         pop     dx
  1281.         ret
  1282.  
  1283. fb_h_line:
  1284.         push    dx
  1285.         push    cx
  1286.         mov     bh,screen_page
  1287.  
  1288.         mov     cl,cursor_x
  1289.         cmp     dl,cl
  1290.         jbe     fbhl_1
  1291.         xchg    dl,cl
  1292.  
  1293. fbhl_1: mov     ah,2            ;set curpos
  1294.         int     10h
  1295.         mov     ah,8
  1296.         int     10h             ;read c/a
  1297.  
  1298.         push    cx
  1299.         mov     bl,attrib
  1300.         mov     cx,1
  1301.         mov     ah,9
  1302.         int     10h             ;write new attrib
  1303.         pop     cx
  1304.  
  1305.         cmp     dl,cl
  1306.         je      fbhl_2
  1307.         inc     dl
  1308.         jmp     fbhl_1
  1309.  
  1310. fbhl_2: pop     cx
  1311.         pop     dx
  1312.         ret
  1313.  
  1314. fb_center:
  1315.         push    dx
  1316.         mov     ah,3
  1317.         int     10h
  1318.         pop     cx
  1319.         push    dx
  1320.         mov     dx,cx
  1321.         mov     ah,2
  1322.         int     10h
  1323.         
  1324.         mov     ah,8
  1325.         int     10h
  1326.         push    cx
  1327.         mov     bl,7*16
  1328.         mov     cx,1
  1329.         mov     ah,9
  1330.         int     10h
  1331.         pop     cx
  1332.  
  1333.         pop     dx
  1334.         mov     ah,2
  1335.         int     10h
  1336.         mov     dx,cx
  1337.         ret
  1338.  
  1339.  
  1340. mu_putdown:
  1341.         call    save_screen     ;save for later undo
  1342.         mov     al,attrib
  1343.         push    ax
  1344.         mov     ins_del_flag,255
  1345.  
  1346.         mov     bh,screen_page
  1347.         mov     ah,3
  1348.         int     10h             ;get curpos
  1349.         push    dx              ;save it
  1350.  
  1351.         mov     ah,22
  1352.         xchg    ah,dh
  1353.         sub     dh,ah
  1354.         mov     al,79
  1355.         xchg    al,dl
  1356.         sub     dl,al
  1357.  
  1358.         mov     cx,paste_size
  1359.         cmp     dh,ch           ;take smaller of two
  1360.         jbe     mupd_1
  1361.         mov     dh,ch
  1362. mupd_1: cmp     dl,cl
  1363.         jbe     mupd_2
  1364.         mov     dl,cl
  1365.  
  1366. mupd_2: mov     si,offset paste_buffer
  1367.         mov     cl,dh           ;get # lines to do
  1368.         mov     ch,0            ;into CX
  1369.         mov     bl,dl           ;get # cols
  1370.         mov     bh,0            ;into BX
  1371.         pop     dx              ;get cursor pos
  1372.         push    dx
  1373.  
  1374. mupd_4: push    dx              ;save cursor pos
  1375.         push    cx              ;save # lines to do
  1376.         push    si              ;save current paste_buffer position
  1377.         mov     cx,bx           ;get # cols to do
  1378.  
  1379. mupd_3: push    cx              ;save # cols left
  1380.         push    bx              ;save total cols to do
  1381.         mov     bh,screen_page
  1382.  
  1383.         mov     ah,2            ;set curpos
  1384.         int     10h
  1385.  
  1386.         lodsw                   ;get c/a from p_buff
  1387.         mov     attrib,ah
  1388.         push    dx
  1389.         push    si
  1390.         call    alt_modes
  1391.         pop     si
  1392.         pop     dx
  1393.         mov     cx,1
  1394.         mov     ah,9
  1395.         int     10h             ;write c/a from buffer
  1396.  
  1397.         pop     bx
  1398.         pop     cx              ;get # chrs to do
  1399.         inc     dl              ;next csr col
  1400.         loop    mupd_3
  1401.         pop     si              ;restore start of line in paste buffer
  1402.         mov     cx,paste_size
  1403.         mov     ch,0
  1404.         add     cx,cx
  1405.         add     si,cx
  1406.         pop     cx              ;get # lines left to do
  1407.         pop     dx              ;restore cursor pos
  1408.         inc     dh
  1409.         loop    mupd_4
  1410.  
  1411.         pop     dx
  1412.         mov     bh,screen_page
  1413.         mov     ah,2
  1414.         int     10h             ;restore curpos
  1415.  
  1416.         pop     ax
  1417.         mov     attrib,al
  1418.         mov     ins_del_flag,0
  1419.         ret
  1420.  
  1421. Macro_mess_1 db esc,'[24;1f',esc,'I give up. If you want macros, use ProKey or something.$'
  1422.  
  1423.  
  1424. MU_ascii:
  1425.         call    save_cur
  1426.         call    save_screen
  1427.         mov     dx,offset ascii_table_data
  1428.         dos     9
  1429.         wait_for_key
  1430.         call    restore_screen
  1431.         call    restore_cur
  1432.         ret
  1433.  
  1434. cmd_f:
  1435. MU_flip:
  1436.         mov     dx,offset screen_buffer_2
  1437.         cmp     screen_buffer, offset screen_buffer_1
  1438.         je      MUF_set
  1439.         mov     dx,offset screen_buffer_1
  1440. MUF_set:
  1441.         push    dx
  1442.         call    save_screen
  1443.         pop     dx
  1444.         mov     screen_buffer,dx
  1445.         call    restore_screen
  1446.         ret
  1447.  
  1448.  
  1449. wipe_prompt_1 db esc,'[24;1fAttributes, Text or Both (a/t/b)? $'
  1450. wipe_prompt_2 label byte
  1451. quit_prompt db esc,'[24;1fAre you sure (y/n)? $'
  1452. command_prompt db esc,'[24;1f',esc,'[0mCommand: $'
  1453. save_prompt db esc,'[24;1fSave to $'
  1454. CL_prompt db esc,'[24;1fLoad from $'
  1455. home db esc,'[1;1f$'
  1456. CL_err_mess db esc,'[24;1fError in Loading of file. Hit key to resume editing.$'
  1457. CS_err_mess db esc,'[24;1fError: Couldn',27h,'t save file. Hit key to resume editing.$'
  1458. crlf db 13,10
  1459. ctrl_z db 26
  1460.  
  1461.  
  1462. save_cur:
  1463.         mov     bh,screen_page
  1464.         mov     ah,3
  1465.         int     10h
  1466.         mov     cursor,dx
  1467.         ret
  1468.  
  1469. restore_cur:
  1470.         mov     bh,screen_page
  1471.         mov     ah,2
  1472.         mov     dx,cursor
  1473.         int     10h
  1474.         ret
  1475.  
  1476. no_bak_error db esc,'[24;1fError in renaming to .BAK. Continue (y/n)? $'
  1477.  
  1478. get_filespec:
  1479.         call    print_cs
  1480.         call    save_screen
  1481.         push    si
  1482.         mov     dx,offset filespec_buffer
  1483.         mov     si,dx
  1484.         mov     bl,[si+1]
  1485.         mov     bh,0
  1486.         mov     byte ptr [si+bx+2],13
  1487.         xchg    bx,si
  1488.         pop     si
  1489.         mov     ah,0Ah
  1490.         int     21h             ;input filename
  1491.         mov     bx,offset filespec_buffer+2
  1492.         mov     dx,bx
  1493.         mov     al,[bx-1]
  1494.         mov     ah,0
  1495.         or      ax,ax
  1496.         jz      GF_err
  1497.         add     bx,ax
  1498.         mov     byte ptr [bx],0
  1499.         push    bx
  1500.  
  1501. ;open file for r/w
  1502.         test    create,255
  1503.         jnz     GF_create
  1504.  
  1505.         mov     al,2
  1506.         push    dx
  1507.         mov     ah,3Dh
  1508.         int     21h
  1509.         pop     dx
  1510.         pop     bx
  1511.         jnc     get_fs_ret
  1512. GF_err: jmp     get_fs_ret_err
  1513. GF_create:
  1514.         mov     al,2
  1515.         push    dx
  1516.         mov     ah,3dh
  1517.         int     21h             ;open file for read/write
  1518.         pop     dx
  1519.         push    di
  1520.         jc      GFC_1           ;go create if not found
  1521.         push    dx              ;save $ addr
  1522.         mov     bx,ax           ;get handle
  1523.         dos     3Eh             ;close file
  1524.         pop     dx              ;get $ addr
  1525.  
  1526.  
  1527.         mov     bx,dx           ;get $ addr
  1528.         mov     di,offset buffer
  1529.  
  1530. GFC_2:  mov     al,[bx]         ;get char
  1531.         cmp     al,0            ;eos?
  1532.         jz      GF_bak
  1533.         cmp     al,'.'          ;start of .EXT?
  1534.         je      GF_bak
  1535.         inc     bx
  1536.         stosb                   ;save byte of $
  1537.         jmp     GFC_2
  1538.  
  1539. GF_bak: mov     al,'.'          ;ext marker
  1540.         stosb
  1541.         mov     al,'B'
  1542.         stosb
  1543.         mov     al,'A'
  1544.         stosb
  1545.         mov     al,'K'
  1546.         stosb   
  1547.         mov     al,0
  1548.         stosb
  1549.         mov     di,offset buffer     ;get ptr to .bak $
  1550.  
  1551.         push    dx              ;save $ addr
  1552.         mov     dx,di           ;get .bak filespec
  1553.         dos     41h             ;delete .bak
  1554.         pop     dx
  1555.  
  1556.         push    dx
  1557.         dos     56H             ;rename file to .BAK
  1558.         pop     dx
  1559.         jnc     GFC_1
  1560.         push    dx
  1561.         mov     dx,offset no_bak_error
  1562.         dos     9
  1563.         pop     dx
  1564. GFC_3:  wait_for_key
  1565.         call    capit_al
  1566.         cmp     al,'Y'
  1567.         je      GFC_1
  1568.         cmp     al,'N'
  1569.         jne     GFC_3
  1570.         pop     di
  1571.         pop     bx
  1572.         jmp short get_fs_ret_err
  1573.   
  1574. GFC_1:  pop     di              ;restore di
  1575.         mov     ah,3Ch
  1576.         mov     cx,0
  1577.         mov     al,2
  1578.         int     21h
  1579.         pop     bx
  1580.         jnc     get_fs_ret
  1581. get_fs_ret_err:
  1582.         stc
  1583. get_fs_ret:
  1584.         mov     byte ptr [bx],13     ;set buffer back to normal
  1585.         call    restore_screen
  1586.         ret
  1587.  
  1588. adjust:
  1589.         mov     dl,max_col
  1590.         mov     dh,cur_line
  1591.         
  1592. adjust_loop:
  1593.         dec     dl
  1594.         cmp     dl,255
  1595.         jz      adjust_end
  1596.         mov     ah,2
  1597.         mov     bh,screen_page
  1598.         int     10h             ;set cur_pos
  1599.         mov     ah,8
  1600.         mov     bh,screen_page
  1601.         int     10h
  1602.         cmp     al,0
  1603.         je      adjust_loopB
  1604.         cmp     al,255
  1605.         je      adjust_loopB
  1606.         cmp     al,32
  1607.         je      adjust_loopB
  1608. adjust_end:
  1609.         inc     dl
  1610.         mov     max_col,dl
  1611. A_ret:
  1612.         ret
  1613.  
  1614. adjust_loopB:
  1615.         and     ah,7*16         ;test for background color on.
  1616.         jz      adjust_loop
  1617.         jmp     adjust_end
  1618.   
  1619. write_spaces:
  1620.         cmp     space_count,6   ;more than 5 spaces queued?
  1621.         jc      WS_no           ;no
  1622.         push    ax
  1623.         push    dx
  1624.         mov     byte ptr [bp],esc
  1625.         inc     bp
  1626.         mov     byte ptr [bp],'['
  1627.         inc     bp
  1628.         mov     al,space_count
  1629.         mov     ah,0
  1630.         mov     dl,10
  1631.         div     dl
  1632.         or      al,al
  1633.         jz      WS_skip_1st
  1634.         add     al,48           ;make ASCII #
  1635.         mov     [bp],al
  1636.         inc     bp
  1637. WS_skip_1st:
  1638.         add     ah,48
  1639.         mov     byte ptr [bp],ah
  1640.         inc     bp
  1641.         mov     byte ptr [bp],'C'
  1642.         inc     bp
  1643.         mov     space_count,0
  1644.         pop     dx
  1645.         pop     ax
  1646.         ret
  1647. WS_no:  push    cx
  1648.         push    ax
  1649.         mov     al,32
  1650.         mov     cl,space_count
  1651.         xor     ch,ch
  1652. WS_1:   mov     [bp],al
  1653.         inc     bp
  1654.         loop    WS_1
  1655.         mov     space_count,0
  1656.         pop     ax
  1657.         pop     cx
  1658.         ret
  1659.  
  1660. FA_1:   test    space_count,255 ;any spaces queued?
  1661.         jnz     FA_2
  1662.         test    attrib,16+32+64 ;background 0?
  1663.         jnz     FA_1b
  1664.  
  1665. FA_2:   push    ax
  1666.         mov     al,attrib
  1667.         and     al,240-128      ;mask all but background
  1668.         and     ah,240-128
  1669.         cmp     al,ah           ;are they the same
  1670.         pop     ax              ;restore c/a
  1671.         jne     FA_1_no_leave
  1672.         inc     space_count
  1673.         jmp     A_ret_2         ;return w/o writing
  1674. FA_1_no_leave:
  1675.         call    write_spaces
  1676.         jmp     FA_1b
  1677.  
  1678. A_ret_2:
  1679.         pop     bp
  1680.         jmp     A_ret_3
  1681.  
  1682. fix_attrib:
  1683.         push    dx
  1684.         push    cx
  1685.         push    bx
  1686.         push    ax              ;save c/a
  1687.         mov     bp,offset buffer
  1688.         push    bp
  1689.  
  1690.         mov     write,no
  1691.         cmp     al,32           ;is char a space?
  1692.         je      FA_1            ;yes, go process
  1693.         test    space_count,255 ;are spaces queued?
  1694.         jz      FA_1b
  1695.         call    write_spaces
  1696.  
  1697. FA_1b:  mov     write,yes
  1698. FA_1c:  cmp     ah,attrib
  1699.         je      FA_save
  1700.         mov     byte ptr [bp],esc
  1701.         inc     bp
  1702.         mov     byte ptr [bp],'['
  1703.         inc     bp
  1704.  
  1705.         mov     attrib,ah
  1706.         mov     byte ptr [bp],'0'
  1707.         inc     bp
  1708.         mov     byte ptr [bp],';'
  1709.         inc     bp
  1710.         mov     byte ptr [bp],'3'
  1711.         inc     bp
  1712.         and     ah,7
  1713.         call    xlat_colors
  1714.         add     ah,30h          ;make decimal
  1715.         mov     byte ptr [bp],ah
  1716.         inc     bp
  1717.         mov     byte ptr [bp],';'
  1718.         inc     bp
  1719.         test    attrib,16+32+64 ;background set?
  1720.         jz      no_background
  1721.         mov     byte ptr [bp],'4'
  1722.         inc     bp
  1723.         mov     ah,attrib
  1724.         mov     cl,4
  1725.         ror     ah,cl
  1726.         and     ah,7
  1727.         call    xlat_colors
  1728.         add     ah,30h
  1729.         mov     byte ptr [bp],ah
  1730.         inc     bp
  1731.         mov     byte ptr [bp],';'
  1732.         inc     bp
  1733. no_background:
  1734.         test    attrib,8
  1735.         jz      no_intensity
  1736.         mov     byte ptr [bp],'1'
  1737.         inc     bp
  1738.         mov     byte ptr [bp],';'
  1739.         inc     bp
  1740. no_intensity:
  1741.         test    attrib,128
  1742.         jz      no_blinking
  1743.         mov     byte ptr [bp],'5'
  1744.         inc     bp
  1745.         inc     bp
  1746. no_blinking:
  1747.         dec     bp
  1748.         mov     byte ptr [bp],'m'
  1749.         inc     bp
  1750. FA_save:
  1751.         pop     cx
  1752.         push    cx              ;save pointer to buffer
  1753.         xchg    cx,bp
  1754.         sub     cx,bp
  1755.         pop     bp              ;restore ptr
  1756.         jcxz    A_ret_3
  1757.         mov     dx,offset buffer
  1758.         mov     ah,40h
  1759.         mov     bx,handle
  1760.         int     21h
  1761. A_ret_3:
  1762.         pop     ax
  1763.         pop     bx
  1764.         pop     cx
  1765.         pop     dx
  1766.         ret
  1767.  
  1768. colors db 0,4,2,6,1,5,3,7
  1769.  
  1770. Xlat_Colors:
  1771.         push    bx
  1772.         push    ax
  1773.         mov     al,ah
  1774.         mov     bx,offset colors
  1775.         xlat    colors
  1776.         pop     bx
  1777.         mov     ah,al
  1778.         mov     al,bl
  1779.         pop     bx
  1780.         ret
  1781.  
  1782. color_list db esc,'[24;1f'
  1783.         db esc,'[0;30;5;47mB',esc,'[0;30;47mlack'                  ;Black
  1784.         db esc,'[0;34;1;40m b',esc,'[0;34;1;5mL',esc,'[0;34;1mue ' ;bLue
  1785.         db esc,'[0;32;1;5;40mG',esc,'[0;32;1mreen '                ;Green
  1786.         db esc,'[0;36;1;5;40mC',esc,'[0;36;1myan '                 ;Cyan
  1787.         db esc,'[0;31;1;5;40mR',esc,'[0;31;1med '                  ;Red
  1788.         db esc,'[0;35;1;5;40mM',esc,'[0;35;1magenta '              ;Magenta
  1789.         db esc,'[0;33;1;5;40mY',esc,'[0;33;1mellow '               ;Yellow
  1790.         db esc,'[0;37;1;5;40mW',esc,'[0;37;1mhite '                ;White
  1791.         db '$'
  1792. colors_table db 9, 'BLGCRMYW',ESC
  1793. color_fore_back db esc,'[24;1fForeground or Background (f/b)? $'
  1794. color_blinking_mess db esc,'[24;1fBlinking (y/n)? $'
  1795. color_int_mess db esc,'[24;1fBright (y/n)? $'
  1796.  
  1797. save_prompt2 db esc,'[24;1fAnnex "Clear-Screen" to file (y/n)? ',esc,'[K$'
  1798. cls_file db esc,'[2J'
  1799. len_cls_file=4 
  1800.  
  1801. replace_mess1 db esc,'[24;1fReplace what char? $'
  1802. replace_mess2 db esc,'[24;1fReplace with what? $'
  1803. replace_mess3 db esc,'[24;1fReplace $'
  1804. replace_mess3b db esc,'[C with $'
  1805. replace_mess3c db esc,'[C (y/n)? $'
  1806.  
  1807. char_to_replace db ?
  1808. char_with_which_to_replace db ?
  1809.  
  1810. outchr: push    bx
  1811.         push    ax
  1812.         push    cx
  1813.         mov     bh,0
  1814.         mov     bl,attrib
  1815.         mov     cx,1
  1816.         mov     ah,9
  1817.         int     10h
  1818.         pop     cx
  1819.         pop     ax
  1820.         pop     bx
  1821.         ret
  1822.  
  1823. cmdr_esc:
  1824.         ret
  1825.  
  1826.  
  1827. cmd_R:
  1828.         mov     dx,offset replace_mess1
  1829.         dos     9
  1830.         
  1831. cr_1a:  wait_for_key            ;go get key from BIOS
  1832.     cmp    al,esc            ;esc from routine
  1833.         je      cmdr_esc
  1834.         cmp     al,32
  1835.         jc      cr_1a
  1836.         mov     char_to_replace,al
  1837.  
  1838.         mov     dx,offset replace_mess2
  1839.         dos     9
  1840. CR_1:   wait_for_key
  1841.         cmp     al,esc
  1842.         je      cmdr_esc
  1843.         cmp     al,32
  1844.         jc      CR_1
  1845.         mov     char_with_which_to_replace,al
  1846.  
  1847.         mov     dx,offset replace_mess3
  1848.         dos     9
  1849.         mov     al,char_to_replace
  1850.         call    outchr
  1851.         mov     dx,offset replace_mess3b
  1852.         dos     9
  1853.         mov     al,char_with_which_to_replace
  1854.         call    outchr
  1855.         mov     dx,offset replace_mess3c
  1856.         dos     9
  1857.  
  1858. CR_2:   wait_for_key
  1859.         call    capit_al
  1860.         cmp     al,'N'
  1861.         je      CR_exit
  1862.         cmp     al,'Y'
  1863.         jne     CR_2
  1864.         call    replacement_routine
  1865.  
  1866. cr_exit:
  1867.         ret
  1868.  
  1869. replacement_routine:
  1870.         mov     dx,0            ;screen pos
  1871. CR_3:   mov     bh,0
  1872.         mov     ah,2
  1873.         int     10h             ;set curpos
  1874.         
  1875.         mov     ah,8            ;read char
  1876.         int     10h
  1877.         cmp     al,char_to_replace
  1878.         jne     CR_4
  1879.         mov     al,char_with_which_to_replace
  1880.         mov     bl,ah
  1881.         mov     cx,1
  1882.         mov     ah,9
  1883.         int     10h             ;write replacement char
  1884.  
  1885. CR_4:   inc     dl              ;next column
  1886.         cmp     dl,79           ;last one?
  1887.         jne     CR_3            ;loop until done
  1888.         mov     dl,0
  1889.         inc     dh
  1890.         cmp     dh,22           ;last line?
  1891.         jne     cr_3
  1892.         
  1893.         ret
  1894.  
  1895.  
  1896. graphics_prompt db esc,'[24;1fReplace IBM graphic with others (y/n)? $'
  1897. CG_try2_mess db esc,'[24;1fReplace all ASCII codes >128 with spaces (y/n)? $'
  1898.  
  1899.  
  1900. cmd_g:
  1901.         mov     dx,offset graphics_prompt
  1902.         dos     9
  1903.  
  1904. cg_1:   wait_for_key
  1905.         call    capit_al
  1906.         cmp     al,esc
  1907.         je      cg_exit
  1908.         cmp     al,'N'
  1909.         je      cg_try2
  1910.         cmp     al,'Y'
  1911.         jne     cg_1
  1912.  
  1913.         mov     dx,0
  1914.         mov     bh,0
  1915. CG_2:   mov     ah,2
  1916.         int     10h
  1917.         mov     ah,8
  1918.         int     10h
  1919.         cmp     al,128
  1920.         jc      CG_3
  1921.         mov     bl,ah           ;xfer attrib
  1922.         push    bx
  1923.         mov     bx,offset ibm_list
  1924.         mov     ah,0
  1925.         sub     al,128
  1926.         add     bx,ax
  1927.         mov     al,[bx]         ;get replacement char
  1928.         pop     bx              
  1929.         mov     cx,1
  1930.         mov     ah,9
  1931.         int     10h             ;write new char out
  1932.  
  1933. CG_3:   inc     dl
  1934.         cmp     dl,79
  1935.         jne     CG_2
  1936.         mov     dl,0
  1937.         inc     dh
  1938.         cmp     dh,22
  1939.         jne     cg_2
  1940.         
  1941. CG_exit:
  1942.         ret
  1943. CG_try2:
  1944.         mov     dx,offset CG_try2_mess
  1945.         dos     9
  1946. CG_4:   getkey
  1947.         jz      CG_4
  1948.         call    capit_al
  1949.         cmp     al,'N'
  1950.         je      CG_exit
  1951.         cmp     al,esc
  1952.         je      CG_exit
  1953.         cmp     al,'Y'
  1954.         jne     CG_4
  1955.  
  1956.         mov     dx,0
  1957.         mov     bh,0
  1958. CG_5:   mov     ah,2
  1959.         int     10h
  1960.         mov     ah,8
  1961.         int     10h
  1962.         cmp     al,128
  1963.         jc      CG_6
  1964.         mov     bl,ah
  1965.         mov     al,32
  1966.         mov     cx,1
  1967.         mov     ah,9
  1968.         int     10h
  1969.  
  1970. CG_6:   inc     dl
  1971.         cmp     dl,79
  1972.         jne     CG_5
  1973.         mov     dl,0
  1974.         inc     dh
  1975.         cmp     dh,22
  1976.         jne     CG_5
  1977.         jmp     CG_exit
  1978.  
  1979. ibm_list db 'CueaaaaceeeiiiAAEaAooouuyOU$$$$$aiounN  ?[]  !""@@@'
  1980.          db '|++++++|+++++++++-++++++++-+++++++++++++'
  1981.          db '@@@@@', 255-224+1 dup(32)
  1982.  
  1983. cmd_U:
  1984.         call    restore_screen
  1985.         ret
  1986.  
  1987. cmd_C:
  1988.         mov     dx,offset color_fore_back
  1989.         call    print_cs
  1990. CC_1:   getkey
  1991.         jz      cc_1
  1992.         or      al,al
  1993.         jz      cc_1
  1994.         call    capit_al
  1995.         cmp     al,27
  1996.         je      cc_ret
  1997.         cmp     al,'F'
  1998.         mov     cl,0            ;rotate no bits.
  1999.         je      cc_get_color
  2000.         cmp     al,'B'
  2001.         mov     cl,4
  2002.         je      cc_get_color
  2003.         jmp     cc_1
  2004.  
  2005. cc_ret: ret
  2006.  
  2007. cc_get_color:
  2008.         mov     rotate,cl       ;save distance to rotate
  2009.         mov     dx,offset color_list
  2010.         call    print_cs
  2011. cc_2:   getkey
  2012.         jz      cc_2
  2013.         or      al,al
  2014.         jz      cc_2
  2015.         search  colors_table,ax
  2016.         JNE     CC_2
  2017.         CMP     AH,9
  2018.         JZ      CC_RET
  2019.         dec     ah              ;make a color
  2020.         mov     cl,rotate
  2021.         rol     ah,cl           ;set for attrib pos
  2022.         mov     al,attrib
  2023.         mov     dl,7            ;a mask
  2024.         rol     dl,cl           ;pos it
  2025.         or      al,dl
  2026.         xor     al,dl           ;remove unwanted bits
  2027.         or      al,ah           ;put in new bits
  2028.         mov     attrib,al
  2029.  
  2030.         or      cl,cl           ;doing foreground?
  2031.         jnz     cc_ret          ;no, skip other questions
  2032.  
  2033.         and     al,7+7*16       ;eliminate blink+intensity bits
  2034.         mov     attrib,al
  2035.  
  2036.         mov     dx,offset color_int_mess
  2037.         call    print_cs
  2038. cc_3:   getkey
  2039.         jz      cc_3
  2040.         or      al,al
  2041.         jz      cc_3
  2042.         call    capit_al
  2043.         cmp     al,esc
  2044.         jz      cc_ret
  2045.         cmp     al,'N'
  2046.         jz      cc_4
  2047.         cmp     al,'Y'
  2048.         jne     cc_3
  2049.         or      attrib,8
  2050. cc_4:   mov     dx,offset color_blinking_mess
  2051.         call    print_cs
  2052. cc_5:   getkey
  2053.         jz      cc_5
  2054.         or      al,al
  2055.         jz      cc_5
  2056.         call    capit_al
  2057.         cmp     al,esc
  2058.         jz      cc_ret2
  2059.         cmp     al,'N'
  2060.         jz      cc_ret2
  2061.         cmp     al,'Y'
  2062.         jne     cc_5
  2063.         or      attrib,128
  2064. cc_ret2:
  2065.         ret
  2066.  
  2067.  
  2068. CS_error:
  2069.         jmp     Save_error
  2070. cmd_S:
  2071.         mov     create,255
  2072.         mov     dx,offset save_prompt
  2073.         call    get_filespec
  2074.         jc      CS_error
  2075.         mov     handle,ax
  2076.         mov     attrib,7        ;set attrib to default
  2077.         mov     cur_line,21
  2078.  
  2079.         mov     dx,offset save_prompt2
  2080.         mov     ah,9
  2081.         int     21h
  2082. CS_p2:  wait_for_key            ;read char
  2083.         cmp     al,esc          ;don't save?
  2084.         je      CS_error
  2085.         call    capit_al
  2086.         cmp     al,'Y'          ;clear screen at start?
  2087.         jne     CS_p1
  2088.         mov     bx,handle
  2089.         mov     dx,offset cls_file
  2090.         mov     cx,len_cls_file
  2091.         dos     40h             ;write into file
  2092.         jmp     save_start
  2093. CS_p1:  cmp     al,'N'
  2094.         jne     CS_p2
  2095.  
  2096. save_start:
  2097.         cmp     cur_line,0
  2098.         jnz     ss_1
  2099.         jmp     nothing_to_save
  2100. ss_1:   mov     max_col,79
  2101.         call    adjust
  2102.         dec     cur_line
  2103.         cmp     max_col,0
  2104.         jz      save_start
  2105.         mov     al,cur_line
  2106.         inc     al
  2107.         inc     al
  2108.         mov     max_line,al
  2109.         mov     cur_line,0
  2110. Save_loop:
  2111.         mov     max_col,79
  2112.         mov     cur_col,0
  2113.         call    adjust
  2114.         inc     max_col
  2115.         mov     cl,max_col
  2116.         mov     ch,0
  2117.         mov     space_count,0
  2118.         mov     write,yes
  2119.         push    cx
  2120. Save_line:
  2121.         pop     cx
  2122.         dec     cx
  2123.         jcxz    Save_line_done
  2124.         push    cx
  2125.         mov     dl,cur_col
  2126.         mov     dh,cur_line
  2127.         mov     bh,screen_page
  2128.         mov     ah,2
  2129.         int     10h
  2130.         mov     ah,8
  2131.         int     10h             ;get c/a from screen
  2132.         call    fix_attrib
  2133.         cmp     write,no        ;should we write this char?
  2134.         je      sl_1
  2135.         mov     byte ptr [buffer],al
  2136.         mov     cx,1
  2137.         mov     dx,offset buffer
  2138.         mov     ah,40h
  2139.         mov     bx,handle
  2140.         int     21h             ;write chr to file
  2141. SL_1:   inc     cur_col
  2142.         jmp     Save_line
  2143.  
  2144. Save_line_done:
  2145.         inc     cur_line
  2146.         mov     dx,offset crlf
  2147.         mov     cx,2
  2148.         mov     bx,handle
  2149.         mov     ah,40h
  2150.         int     21h
  2151.         mov     al,cur_line
  2152.         cmp     al,max_line
  2153.         jz      Save_done
  2154.         jmp     Save_loop
  2155.  
  2156. Save_done:
  2157. Nothing_to_save:
  2158.         mov     dx,offset ctrl_z
  2159.         mov     cx,1
  2160.         mov     ah,40h
  2161.         mov     bx,handle
  2162.         int     21h
  2163.         jc      Save_error
  2164.         or      ax,ax
  2165.         jz      Save_error
  2166.         call    CL_Ended
  2167.         ret
  2168.  
  2169. Save_error:
  2170.         mov     dx,offset CS_err_mess
  2171.         call    print_cs
  2172.         mov     ah,0Ch
  2173.         mov     al,1
  2174.         int     21h
  2175.         ret
  2176.  
  2177. cmd_L:
  2178.         mov     create,0
  2179.         mov     dx,offset CL_prompt
  2180.         call    get_filespec
  2181.         jc      CL_error_2
  2182.         mov     handle,ax
  2183.         mov     dx,offset home
  2184.         call    print_cs
  2185. CL_loop:
  2186.         mov     bx,handle
  2187.         mov     ah,3Fh
  2188.         mov     cx,1
  2189.         mov     dx,offset buffer
  2190.         int     21h
  2191.         jc      CL_Error
  2192.         or      ax,ax
  2193.         jz      CL_Ended
  2194.  
  2195.         mov     dl,byte ptr [buffer]
  2196.         cmp     dl,26           ;^Z terminating?
  2197.         jz      CL_Ended
  2198.  
  2199.         mov     ah,2
  2200.         int     21h
  2201.         jmp     CL_loop
  2202.  
  2203. CL_Ended:
  2204.         mov     bx,handle
  2205.         mov     ah,3Eh
  2206.         int     21h             ;close file
  2207.         ret
  2208.  
  2209. CL_Error:
  2210.         call    CL_ended        ;close file
  2211. CL_error_2:
  2212.         mov     dx,offset CL_err_mess
  2213.         call    print_cs
  2214.         mov     ah,0Ch
  2215.         mov     al,1
  2216.         int     21h
  2217.         ret
  2218.  
  2219.  
  2220. cmd_Q:
  2221.         mov     dx,offset quit_prompt
  2222.         call    print_cs
  2223. quit_loop:
  2224.         getkey
  2225.         jz      quit_loop
  2226.         or      al,al
  2227.         jz      quit_loop       
  2228.         call    capit_al
  2229.         cmp     al,'N'
  2230.         je      quit_end
  2231.         cmp     al,esc
  2232.         je      quit_end
  2233.         cmp     al,'Y'
  2234.         jne     quit_loop
  2235.         pop     ax
  2236.         stc
  2237.         ret
  2238. quit_end:
  2239.         ret
  2240.  
  2241. cmd_M:
  2242.         ret
  2243. cmd_W:
  2244.         mov     dx,offset wipe_prompt_1
  2245.         call    print_cs
  2246. wl_1:   getkey
  2247.         jz      wl_1
  2248.         or      al,al
  2249.         jz      wl_1
  2250.         call    capit_al
  2251.         cmp     al,esc          ;ESC key hit?
  2252.         jz      wipe_end
  2253.         mov     dx,00FFh        ;attribs?
  2254.         mov     cx,0700h
  2255.         cmp     al,'A'
  2256.         jz      wl_2
  2257.         mov     dx,0FF00h       ;text
  2258.         mov     cx,0020h
  2259.         cmp     al,'T'
  2260.         jz      wl_2
  2261.         mov     dx,0000         ;both
  2262.         mov     cx,0720h
  2263.         cmp     al,'B'
  2264.         jnz     wl_1
  2265.  
  2266. wl_2:   push    dx
  2267.         push    cx
  2268.  
  2269.         mov     dx,offset wipe_prompt_2
  2270.         call    print_cs
  2271. wipe_loop:
  2272.         getkey
  2273.         jz      wipe_loop
  2274.         or      al,al
  2275.         jz      wipe_loop       
  2276.         call    capit_al
  2277.         cmp     al,'N'
  2278.         je      wipe_end
  2279.         cmp     al,esc
  2280.         je      wipe_end
  2281.         cmp     al,'Y'
  2282.         jne     wipe_loop
  2283.  
  2284.         pop     di
  2285.         pop     si
  2286.         mov     dx,0            ;new cursor pos
  2287.         mov     bh,screen_page
  2288.  
  2289. cls2:   mov     ah,2            ;set curpos
  2290.         int     10h
  2291.  
  2292.         mov     ah,8            ;read c/a
  2293.         int     10h
  2294.         and     ax,si           ;clear unwanted part
  2295.         or      ax,di           ;move in new replacement
  2296.         mov     bl,ah
  2297.         mov     cx,1
  2298.         mov     ah,9 
  2299.         int     10h             ;write new c/a
  2300.  
  2301.         inc     dl
  2302.         cmp     dl,79
  2303.         jne     cls2
  2304.         mov     dl,0
  2305.         inc     dh
  2306.         cmp     dh,22
  2307.         jne     cls2
  2308.  
  2309.         mov     cursor,0
  2310.         mov     attrib,7
  2311.  
  2312. wipe_end:
  2313.         ret
  2314.  
  2315. cmd_esc:
  2316.         clc
  2317.         pop     ax
  2318.         call    restore_cur
  2319.         ret
  2320.  
  2321. mode_cmd:
  2322.         mov     dx,offset command_prompt
  2323.         call    print_cs
  2324. MC_key_loop:
  2325.         getkey
  2326.         jz      MC_key_loop
  2327.         search  cmd_key,ax
  2328.         jne     MC_key_loop
  2329.         jump    cmd_table,ah
  2330.         jmp     mode_cmd
  2331.  
  2332. status_line_1 db esc,'[23;1f',esc,'[0;40;33;7mtDoodle 1.11                  '
  2333.         db '     Mode: $'
  2334. status_line_2 db 'Current Attribute',esc,'[0;40;33;7m         Box: $'
  2335. status_line_3 db esc,'[0;6m$'
  2336.  
  2337. status_line_4 db 'Paint  $'
  2338. status_line_5 db 'Text   $'
  2339. status_line_6 db 'Both   $'
  2340.  
  2341. status_line_help db 10,13,esc,'[K'
  2342.         db esc,'[0;1m1',esc,'[0;7mBox   '
  2343.         db esc,'[0;1m 2',esc,'[0;7mGetClr'
  2344.         db esc,'[0;1m 3',esc,'[0;7mRevers'
  2345.         db esc,'[0;1m 4',esc,'[0;7mMode  '
  2346.         db esc,'[0;1m 5',esc,'[0;7mSayClr'
  2347.         db esc,'[0;1m 6',esc,'[0;7mFlip  '
  2348.         db esc,'[0;1m 7',esc,'[0;7mCut   '
  2349.         db esc,'[0;1m 8',esc,'[0;7mPaste '
  2350.         db esc,'[0;1m 9',esc,'[0;7mUndo  '
  2351.         db esc,'[0;1m 0',esc,'[0;7mASCII '
  2352.         db esc,'[0m$'
  2353.  
  2354. display_ctrls:
  2355.         push    cursor
  2356.         call    save_cur
  2357.         mov     dx,offset status_line_1
  2358.         call    print_cs
  2359.  
  2360.         mov     ah,mode
  2361.         mov     cl,5
  2362.         ror     ah,cl
  2363.         mov     dx,offset status_line_6
  2364.         and     ah,3          
  2365.         jz      DC_2
  2366.         mov     dx,offset status_line_4
  2367.         dec     ah
  2368.         jz      DC_2
  2369.         mov     dx,offset status_line_5
  2370. DC_2:   call    print_cs
  2371.  
  2372.         mov     handle,0        ;con:
  2373.         mov     ah,attrib
  2374.         push    ax
  2375.         mov     ah,0            ;force attrib change
  2376.         call    fix_attrib
  2377.         pop     ax
  2378.         call    fix_attrib
  2379.  
  2380.         mov     dx,offset status_line_2
  2381.         call    print_cs
  2382.  
  2383.         mov     al,'S'
  2384.         call    alt_modes
  2385.         cmp     al,'S'
  2386.         jnz     DC_1
  2387.         mov     al,'T'
  2388. DC_1:   mov     dl,al
  2389.         mov     ah,02
  2390.         int     21h
  2391.         mov     dx,offset status_line_3
  2392.         call    print_cs
  2393.  
  2394.         mov     dx,offset status_line_help
  2395.         mov     ah,9
  2396.         int     21h             ;print mess w/no crlf
  2397.  
  2398.         call    restore_cur
  2399.         pop     cursor
  2400.         ret
  2401.  
  2402. ascii_table_data label byte
  2403. db esc,'[H'
  2404. db  27, 91, 48, 59, 51, 50, 59, 49, 109, 201, 205, 205, 205, 205, 205 
  2405. db  205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205 
  2406. db  205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205 
  2407. db  205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205 
  2408. db  205, 205, 205, 187, 13, 10, 186, 27, 91, 48, 59, 51, 51, 109, 49 
  2409. db  50, 56, 32, 128, 32, 32, 49, 52, 52, 32, 144, 32, 32, 49, 54 
  2410. db  48, 32, 160, 32, 32, 49, 55, 54, 32, 176, 32, 32, 49, 57, 50 
  2411. db  32, 192, 32, 32, 50, 48, 56, 32, 208, 32, 32, 50, 50, 52, 32 
  2412. db  224, 32, 32, 50, 52, 48, 32, 27, 91, 48, 59, 51, 50, 59, 49 
  2413. db  109, 186, 13, 10, 186, 27, 91, 48, 59, 51, 54, 59, 49, 109, 49 
  2414. db  50, 57, 32, 129, 32, 32, 49, 52, 53, 32, 145, 32, 32, 49, 54 
  2415. db  49, 32, 161, 32, 32, 49, 55, 55, 32, 177, 32, 32, 49, 57, 51 
  2416. db  32, 193, 32, 32, 50, 48, 57, 32, 209, 32, 32, 50, 50, 53, 32 
  2417. db  225, 32, 32, 50, 52, 49, 32, 27, 91, 48, 59, 51, 50, 59, 49 
  2418. db  109, 186, 13, 10, 186, 27, 91, 48, 59, 51, 51, 109, 49, 51, 48 
  2419. db  32, 130, 32, 32, 49, 52, 54, 32, 146, 32, 32, 49, 54, 50, 32 
  2420. db  162, 32, 32, 49, 55, 56, 32, 178, 32, 32, 49, 57, 52, 32, 194 
  2421. db  32, 32, 50, 49, 48, 32, 210, 32, 32, 50, 50, 54, 32, 226, 32 
  2422. db  32, 50, 52, 50, 32, 27, 91, 48, 59, 51, 50, 59, 49, 109, 186 
  2423. db  13, 10, 186, 27, 91, 48, 59, 51, 54, 59, 49, 109, 49, 51, 49 
  2424. db  32, 131, 32, 32, 49, 52, 55, 32, 147, 32, 32, 49, 54, 51, 32 
  2425. db  163, 32, 32, 49, 55, 57, 32, 179, 32, 32, 49, 57, 53, 32, 195 
  2426. db  32, 32, 50, 49, 49, 32, 211, 32, 32, 50, 50, 55, 32, 227, 32 
  2427. db  32, 50, 52, 51, 32, 27, 91, 48, 59, 51, 50, 59, 49, 109, 186 
  2428. db  13, 10, 186, 27, 91, 48, 59, 51, 51, 109, 49, 51, 50, 32, 132 
  2429. db  32, 32, 49, 52, 56, 32, 148, 32, 32, 49, 54, 52, 32, 164, 32 
  2430. db  32, 49, 56, 48, 32, 180, 32, 32, 49, 57, 54, 32, 196, 32, 32 
  2431. db  50, 49, 50, 32, 212, 32, 32, 50, 50, 56, 32, 228, 32, 32, 50 
  2432. db  52, 52, 32, 27, 91, 48, 59, 51, 50, 59, 49, 109, 186, 13, 10 
  2433. db  186, 27, 91, 48, 59, 51, 54, 59, 49, 109, 49, 51, 51, 32, 133 
  2434. db  32, 32, 49, 52, 57, 32, 149, 32, 32, 49, 54, 53, 32, 165, 32 
  2435. db  32, 49, 56, 49, 32, 181, 32, 32, 49, 57, 55, 32, 197, 32, 32 
  2436. db  50, 49, 51, 32, 213, 32, 32, 50, 50, 57, 32, 229, 32, 32, 50 
  2437. db  52, 53, 32, 27, 91, 48, 59, 51, 50, 59, 49, 109, 186, 13, 10 
  2438. db  186, 27, 91, 48, 59, 51, 51, 109, 49, 51, 52, 32, 134, 32, 32 
  2439. db  49, 53, 48, 32, 150, 32, 32, 49, 54, 54, 32, 166, 32, 32, 49 
  2440. db  56, 50, 32, 182, 32, 32, 49, 57, 56, 32, 198, 32, 32, 50, 49 
  2441. db  52, 32, 214, 32, 32, 50, 51, 48, 32, 230, 32, 32, 50, 52, 54 
  2442. db  32, 27, 91, 48, 59, 51, 50, 59, 49, 109, 186, 13, 10, 186, 27 
  2443. db  91, 48, 59, 51, 54, 59, 49, 109, 49, 51, 53, 32, 135, 32, 32 
  2444. db  49, 53, 49, 32, 151, 32, 32, 49, 54, 55, 32, 167, 32, 32, 49 
  2445. db  56, 51, 32, 183, 32, 32, 49, 57, 57, 32, 199, 32, 32, 50, 49 
  2446. db  53, 32, 215, 32, 32, 50, 51, 49, 32, 231, 32, 32, 50, 52, 55 
  2447. db  32, 27, 91, 48, 59, 51, 50, 59, 49, 109, 186, 13, 10, 186, 27 
  2448. db  91, 48, 59, 51, 51, 109, 49, 51, 54, 32, 136, 32, 32, 49, 53 
  2449. db  50, 32, 152, 32, 32, 49, 54, 56, 32, 168, 32, 32, 49, 56, 52 
  2450. db  32, 184, 32, 32, 50, 48, 48, 32, 200, 32, 32, 50, 49, 54, 32 
  2451. db  216, 32, 32, 50, 51, 50, 32, 232, 32, 32, 50, 52, 56, 32, 27 
  2452. db  91, 48, 59, 51, 50, 59, 49, 109, 186, 13, 10, 186, 27, 91, 48 
  2453. db  59, 51, 54, 59, 49, 109, 49, 51, 55, 32, 137, 32, 32, 49, 53 
  2454. db  51, 32, 153, 32, 32, 49, 54, 57, 32, 169, 32, 32, 49, 56, 53 
  2455. db  32, 185, 32, 32, 50, 48, 49, 32, 201, 32, 32, 50, 49, 55, 32 
  2456. db  217, 32, 32, 50, 51, 51, 32, 233, 32, 32, 50, 52, 57, 32, 27 
  2457. db  91, 48, 59, 51, 50, 59, 49, 109, 186, 13, 10, 186, 27, 91, 48 
  2458. db  59, 51, 51, 109, 49, 51, 56, 32, 138, 32, 32, 49, 53, 52, 32 
  2459. db  154, 32, 32, 49, 55, 48, 32, 170, 32, 32, 49, 56, 54, 32, 186 
  2460. db  32, 32, 50, 48, 50, 32, 202, 32, 32, 50, 49, 56, 32, 218, 32 
  2461. db  32, 50, 51, 52, 32, 234, 32, 32, 50, 53, 48, 32, 27, 91, 48 
  2462. db  59, 51, 50, 59, 49, 109, 186, 13, 10, 186, 27, 91, 48, 59, 51 
  2463. db  54, 59, 49, 109, 49, 51, 57, 32, 139, 32, 32, 49, 53, 53, 32 
  2464. db  155, 32, 32, 49, 55, 49, 32, 171, 32, 32, 49, 56, 55, 32, 187 
  2465. db  32, 32, 50, 48, 51, 32, 203, 32, 32, 50, 49, 57, 32, 219, 32 
  2466. db  32, 50, 51, 53, 32, 235, 32, 32, 50, 53, 49, 32, 27, 91, 48 
  2467. db  59, 51, 50, 59, 49, 109, 186, 13, 10, 186, 27, 91, 48, 59, 51 
  2468. db  51, 109, 49, 52, 48, 32, 140, 32, 32, 49, 53, 54, 32, 156, 32 
  2469. db  32, 49, 55, 50, 32, 172, 32, 32, 49, 56, 56, 32, 188, 32, 32 
  2470. db  50, 48, 52, 32, 204, 32, 32, 50, 50, 48, 32, 220, 32, 32, 50 
  2471. db  51, 54, 32, 236, 32, 32, 50, 53, 50, 32, 27, 91, 48, 59, 51 
  2472. db  50, 59, 49, 109, 186, 13, 10, 186, 27, 91, 48, 59, 51, 54, 59 
  2473. db  49, 109, 49, 52, 49, 32, 141, 32, 32, 49, 53, 55, 32, 157, 32 
  2474. db  32, 49, 55, 51, 32, 173, 32, 32, 49, 56, 57, 32, 189, 32, 32 
  2475. db  50, 48, 53, 32, 205, 32, 32, 50, 50, 49, 32, 221, 32, 32, 50 
  2476. db  51, 55, 32, 237, 32, 32, 50, 53, 51, 32, 27, 91, 48, 59, 51 
  2477. db  50, 59, 49, 109, 186, 13, 10, 186, 27, 91, 48, 59, 51, 51, 109 
  2478. db  49, 52, 50, 32, 142, 32, 32, 49, 53, 56, 32, 158, 32, 32, 49 
  2479. db  55, 52, 32, 174, 32, 32, 49, 57, 48, 32, 190, 32, 32, 50, 48 
  2480. db  54, 32, 206, 32, 32, 50, 50, 50, 32, 222, 32, 32, 50, 51, 56 
  2481. db  32, 238, 32, 32, 50, 53, 52, 32, 27, 91, 48, 59, 51, 50, 59 
  2482. db  49, 109, 186, 13, 10, 186, 27, 91, 48, 59, 51, 54, 59, 49, 109 
  2483. db  49, 52, 51, 32, 143, 32, 32, 49, 53, 57, 32, 159, 32, 32, 49 
  2484. db  55, 53, 32, 175, 32, 32, 49, 57, 49, 32, 191, 32, 32, 50, 48 
  2485. db  55, 32, 207, 32, 32, 50, 50, 51, 32, 223, 32, 32, 50, 51, 57 
  2486. db  32, 239, 32, 32, 50, 53, 53, 32, 27, 91, 48, 59, 51, 50, 59 
  2487. db  49, 109, 186, 13, 10, 200, 205, 205, 205, 205, 205, 205, 205, 205, 205 
  2488. db  205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205 
  2489. db  205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205 
  2490. db  205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 188 
  2491. db  13, 10,'$'
  2492.  
  2493.  
  2494. screen_buffer_1 label word
  2495.         org     $+1760*2+2
  2496. screen_buffer_2 label word
  2497.         org     $+1760*2+2
  2498. paste_buffer label byte
  2499.         org     $+1760*2+2
  2500. end_of_code label byte
  2501.  
  2502. cseg    ends
  2503.         end     start
  2504.